package net.lainiao.zhihu.common;

/**
 * 我的Mybatis分页类
 */
public class MyPage {
    /**
     * 每页先是数量
     */
    private int pageSize=20;
    /**
     * 当前页
     */
    private int currentPage=1;
    /**
     * 总记录数
     */
    private int total;
    /**
     * 总页数
     */
    private int totalPage;
    /**
     * 其他参数
     */
    private Object object;
    private String limitStart;

    public Object getObject() {
        return object;
    }

    public void setObject(Object object) {
        this.object = object;
    }
    public int getTotalPage() {
        return totalPage;
    }

    public void setTotalPage(int totalPage) {
        this.totalPage = totalPage;
    }

    public int getPageSize() {
        return pageSize;
    }

    public void setPageSize(int pageSize) {
        this.pageSize = pageSize;
    }

    public int getCurrentPage() {
        return currentPage;
    }

    public void setCurrentPage(int currentPage) {
        this.currentPage = currentPage;
    }

    public int getTotal() {
        return total;
    }

    /**
     * 设置总计路数并计算相关参数
     * @param total
     */
    public void setTotal(int total) {
        this.total = total;
        this.totalPage=this.total/this.pageSize;
        if(this.total%pageSize!=0){
            this.totalPage+=1;
        }
    }

    /**
     * 获取其实查询位置
     * @return
     */
    public int getLimitStart() {
        return (this.currentPage-1)*pageSize;
    }
}
